Skip to content

test(sketchdb): HTTP e2e for capability-miss feedback loop - #55

Merged
zzylol merged 1 commit into
mainfrom
test/sketchdb-capability-miss-e2e
Apr 21, 2026
Merged

zzylol merged 1 commit into
mainfrom
test/sketchdb-capability-miss-e2e

Conversation

@zzylol

@zzylol zzylol commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Addresses TODO.md blocker #3. Complements the in-process `e2e_feedback_loop_tests` in `simple_engine.rs` by adding the full HTTP round-trip:

```
backend /api/v1/query → engine-miss →
HttpControllerClient POST /api/v1/plan (mock controller) →
controller POSTs canned StreamingConfig YAML back to
backend /api/v1/streaming-config →
backend GET /api/v1/streaming-config reflects the new plan.
```

New tests

`tests/capability_miss_http_e2e_tests.rs`:

  • `http_capability_miss_feedback_loop_closes_over_http` — measures `time_to_plan_ready` (localhost floor ~20 ms), asserts the exact `agg_id` the controller pushed is present on the backend, and verifies the mock controller observed the documented `{kind: "capability_miss", ...}` payload.
  • `http_capability_miss_repeat_query_is_idempotent_over_http` — proves a repeat query on the now-covered metric does NOT trigger a second capability-miss notify, locking down the loop's idempotency guarantee at the HTTP boundary.

Scope

Documented in the module preamble: OTLP data ingestion between the plan push and the repeat query is deferred to the cross-process compose harness tracked in `DataCollector/TODO.md` — what this file locks down is the HTTP-boundary behaviour of the feedback loop.

Status

777 → 779 tests. clippy + fmt clean.

🤖 Generated with Claude Code

Addresses TODO.md blocker #3. Complements the in-process
`e2e_feedback_loop_tests` in `simple_engine.rs` (which swaps the
`HotReloadStreamingConfig` directly from a mock `ControllerClient`)
by adding the full HTTP round-trip:

  backend /api/v1/query → engine-miss →
  HttpControllerClient POST /api/v1/plan (mock controller) →
  controller POSTs canned StreamingConfig YAML back to
  backend /api/v1/streaming-config →
  backend GET /api/v1/streaming-config reflects the new plan.

Two tests in `tests/capability_miss_http_e2e_tests.rs`:

* `http_capability_miss_feedback_loop_closes_over_http` —
  measures `time_to_plan_ready` (localhost floor ~20 ms),
  asserts the exact agg_id the controller pushed is present on
  the backend, and verifies the mock controller observed the
  documented `{kind: "capability_miss", ...}` payload.
* `http_capability_miss_repeat_query_is_idempotent_over_http` —
  proves a repeat query on the now-covered metric does NOT
  trigger a second capability-miss notify, locking down the
  loop's idempotency guarantee at the HTTP boundary.

Scope note documented in the module preamble: OTLP data
ingestion between the plan push and the repeat query is
deferred to the cross-process compose harness tracked in
DataCollector/TODO.md — what this file locks down is the
HTTP-boundary behaviour of the feedback loop.

Test count: 777 → 779.
@zzylol
zzylol merged commit 49de64b into main Apr 21, 2026
@zzylol
zzylol deleted the test/sketchdb-capability-miss-e2e branch April 21, 2026 12:39
zzylol added a commit that referenced this pull request Apr 21, 2026
Splits `CountMinSketchWithHeap` out of the plain-CMS branch in
`AccuracyProfile::derive` and gives it its own bound:

  * per-item frequency: e/w    (CMS, Cormode-Muthukrishnan 2005)
  * top-K retention:    1/k    (Metwally et al., ICDT 2005)
  → reported ε = max(e/w, 1/k); δ = 1/2^d (CMS depth)
  → new `AccuracyKind::TopK` variant (serialised as "top_k")

Heap size `k` is read from `parameters.heap_size` (or aliases
`topk` / `k`), default 100.

## Why split

Plain CMS has *per-key point-lookup* accuracy; CMS-with-heap
further guarantees *top-K retention* — items with true
frequency ≥ N·ε are guaranteed to be in the returned heap.
Conflating the two bounds under `AdditiveFrequency` lost the
retention guarantee, which is what users actually query the
heap for.

## Tests

+4 on top of #55's 5:

  cms_with_heap_carries_top_k_kind_and_heap_bound
  cms_with_heap_cms_bound_dominates_when_heap_is_generous
  cms_with_heap_uses_default_heap_size_100
  cms_with_heap_accepts_alternative_param_names

784 → 788 lib tests green; clippy + fmt clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant